/* $Id: JMap.java 63 2010-02-14 13:52:34Z aaron.day $ */
package org.crazydays.gameplan.map.swing;


import java.awt.Dimension;
import java.awt.Graphics;

import org.crazydays.gameplan.map.GameMap;
import org.crazydays.gameplan.swing.AbstractScrollableComponent;

/**
 * JMap is the visual representation of the game map.
 */
public class JMap
    extends AbstractScrollableComponent
{
    /** serial version uid */
    public final static long serialVersionUID =
        "$Id: JMap.java 63 2010-02-14 13:52:34Z aaron.day $".hashCode();

    /** game map */
    protected GameMap gameMap;

    /**
     * JMap constructor.
     * 
     * @param gameMap Game map
     */
    public JMap(GameMap gameMap)
    {
        this.gameMap = gameMap;
        setSize(gameMap.getGeometry().getWidth(), gameMap.getGeometry()
            .getHeight());
    }

    /**
     * Get preferred size.
     * 
     * @return Size
     * @see java.awt.Component#getPreferredSize()
     */
    @Override
    public Dimension getPreferredSize()
    {
        return new Dimension(gameMap.getGeometry().getWidth(), gameMap
            .getGeometry().getHeight());
    }

    /**
     * Paint image.
     * 
     * @param graphics Graphics
     * @see Component#paint(Graphics)
     */
    @Override
    public void paint(Graphics graphics)
    {
        graphics.drawImage(gameMap.getImage(), 0, 0, null);
    }
}
